<?php

/**
 * This is the model class for table "lusi_transactions".
 *
 * The followings are the available columns in table 'lusi_transactions':
 * @property string $id
 * @property string $registerred_course_id
 * @property string $member_id
 * @property string $total_amount
 * @property double $discount_value
 * @property string $transaction_note
 * @property string $transaction_type
 * @property string $transaction_date
 *
 * The followings are the available model relations:
 * @property Members $member
 * @property RegisterredCourses $registerredCourse
 */
class Transactions extends CActiveRecord
{
	/**
	 * @var string
	 */
	public $id;

	/**
	 * @var string
	 */
	public $registerred_course_id;

	/**
	 * @var string
	 */
	public $member_id;

	/**
	 * @var string
	 */
	public $total_amount;

	/**
	 * @var double
	 */
	public $discount_value;

	/**
	 * @var string
	 */
	public $transaction_note;

	/**
	 * @var string
	 */
	public $transaction_type;

	/**
	 * @var string
	 */
	public $transaction_date;


 	/**
	 * @var Members
	 */
	 public $Members;

 	/**
	 * @var RegisterredCourses
	 */
	 public $RegisterredCourses;

	/**
	 * Returns the static model of the specified AR class.
	 * @return Transactions the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'lusi_transactions';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, registerred_course_id, member_id, total_amount, discount_value, transaction_note, transaction_type, transaction_date', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'member' => array(self::BELONGS_TO, 'Members', 'member_id'),
			'registerredCourse' => array(self::BELONGS_TO, 'RegisterredCourses', 'registerred_course_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'registerred_course_id' => 'Registerred Course',
			'member_id' => 'Member',
			'total_amount' => 'Total Amount',
			'discount_value' => 'Discount Value',
			'transaction_note' => 'Transaction Note',
			'transaction_type' => 'Transaction Type',
			'transaction_date' => 'Transaction Date',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('member_id',$this->member_id,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}